package cn.edu.lingnan.servlet.project;

import cn.edu.lingnan.pojo.Project;
import cn.edu.lingnan.service.ProjectService;
import cn.edu.lingnan.service.ProjectServiceImp;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/rejectproject")
public class RejectProjectServlet extends HttpServlet {
    private ProjectService projectService= new ProjectServiceImp();

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html;charset=UTF-8");
        Integer projectId =Integer.parseInt( req.getParameter("projectId"));
        String rejectionReason = req.getParameter("rejectionReason");
        Integer i = projectService.RejectedProject(projectId, -1, rejectionReason);
        List<Project> studnetCreateProject = projectService.QueryStudnetCreateProject();
        req.getSession().setAttribute("studnetCreateProject",studnetCreateProject);
        resp.sendRedirect("manager_AudltSudentCreateProject.jsp");  // replace with your JSP page path

    }
}
